package com.jprocms.module.cms.content;

import com.jprocms.module.cms.framework.enums.EnumContentEvent;
import lombok.AllArgsConstructor;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.validation.annotation.Validated;

import java.util.List;

/**
 * {@link ContentAppEvent} 的生产者
 *
 * @author jprocms
 */
@AllArgsConstructor
@Validated
public class ContentEventPublisher {

    private final ApplicationEventPublisher publisher;

    public void sendContentCreateUpdateEvent(Long id, EnumContentEvent event) {
        ContentAppEvent contentAppEvent = new ContentAppEvent(this, id, event);
        publisher.publishEvent(contentAppEvent);
    }

    public void sendContentDeleteEvent(List<Long> ids) {
        ContentAppEvent contentAppEvent = new ContentAppEvent(this, ids, EnumContentEvent.delete);
        publisher.publishEvent(contentAppEvent);
    }

}
